package com.ruoyi.erp.goodpath.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.erp.goodpath.domain.DeliveryRouteTab;
import com.ruoyi.erp.goodpath.mapper.GoodPathMapper;
import com.ruoyi.erp.goodpath.service.GoodPathService;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * @version 2017.1.1
 * @Auther Du Ruifang @萌えキュンキュン
 * @Date 2020/12/11 14:00
 * @description 该类的作用
 */
@Service
public class GoodsPathServiceImpl implements GoodPathService {
    @Autowired
    private GoodPathMapper goodPathMapper;
    @Override
    public List<DeliveryRouteTab> getList(DeliveryRouteTab deliveryRouteTab) {
        return goodPathMapper.getList(deliveryRouteTab);
    }

    @Override
    public void saveGoodPath(DeliveryRouteTab deliveryRouteTab) {
        deliveryRouteTab.setRowversion(new Date());
        String s = UUID.randomUUID().toString().replace("-", "").toUpperCase();
        String s1 = RandomStringUtils.randomNumeric(10);
        deliveryRouteTab.setRowkey(s+""+s1);
        goodPathMapper.saveGoodPath(deliveryRouteTab);
    }

    @Override
    public String checkRouteId(String routeId) {
       List<DeliveryRouteTab> deliveryRouteTabList= goodPathMapper.checkRouteId(routeId);
       if(deliveryRouteTabList!=null&&deliveryRouteTabList.size()>0) {
           return "1";
       }
        return "0";
    }

    @Override
    public DeliveryRouteTab findGoodPath(String routeId) {
        return goodPathMapper.findGoodPath(routeId);
    }

    @Override
    public void editSaveGoodPath(DeliveryRouteTab deliveryRouteTab) {
        goodPathMapper.editSaveGoodPath(deliveryRouteTab);
    }

    @Override
    public int deleteGoodPathByIds(String ids)  {
        String[] routeIds = Convert.toStrArray(ids);
        return goodPathMapper.deleteGoodPathByIds(routeIds);
    }
}
